// $ANTLR 3.2 Sep 23, 2009 12:02:23 /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g 2010-10-04 17:25:44

package org.javanile.smal.parser;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

public class smalParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "ID", "INT", "EXPONENT", "FLOAT", "COMMENT", "WS", "ESC_SEQ", "STRING", "CHAR", "HEX_DIGIT", "UNICODE_ESC", "OCTAL_ESC", "'('", "')'", "'define'", "'select'"
    };
    public static final int EXPONENT=6;
    public static final int UNICODE_ESC=14;
    public static final int OCTAL_ESC=15;
    public static final int CHAR=12;
    public static final int HEX_DIGIT=13;
    public static final int INT=5;
    public static final int FLOAT=7;
    public static final int ID=4;
    public static final int EOF=-1;
    public static final int T__19=19;
    public static final int T__16=16;
    public static final int WS=9;
    public static final int ESC_SEQ=10;
    public static final int T__18=18;
    public static final int T__17=17;
    public static final int COMMENT=8;
    public static final int STRING=11;

    // delegates
    // delegators


        public smalParser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public smalParser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        

    public String[] getTokenNames() { return smalParser.tokenNames; }
    public String getGrammarFileName() { return "/home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g"; }



    // $ANTLR start "main"
    // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:10:1: main : lists ;
    public final void main() throws RecognitionException {
        try {
            // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:10:6: ( lists )
            // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:10:8: lists
            {
            pushFollow(FOLLOW_lists_in_main23);
            lists();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "main"


    // $ANTLR start "lists"
    // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:13:1: lists : list lists ;
    public final void lists() throws RecognitionException {
        try {
            // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:13:7: ( list lists )
            // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:13:9: list lists
            {
            pushFollow(FOLLOW_list_in_lists33);
            list();

            state._fsp--;

            pushFollow(FOLLOW_lists_in_lists35);
            lists();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "lists"


    // $ANTLR start "list"
    // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:16:1: list : ( head '(' ')' | head '(' first tail ')' );
    public final void list() throws RecognitionException {
        smalParser.head_return head1 = null;


        try {
            // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:16:6: ( head '(' ')' | head '(' first tail ')' )
            int alt1=2;
            int LA1_0 = input.LA(1);

            if ( (LA1_0==ID||(LA1_0>=18 && LA1_0<=19)) ) {
                int LA1_1 = input.LA(2);

                if ( (LA1_1==16) ) {
                    int LA1_2 = input.LA(3);

                    if ( (LA1_2==17) ) {
                        alt1=1;
                    }
                    else if ( (LA1_2==ID) ) {
                        alt1=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 1, 2, input);

                        throw nvae;
                    }
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 1, 1, input);

                    throw nvae;
                }
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 1, 0, input);

                throw nvae;
            }
            switch (alt1) {
                case 1 :
                    // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:16:8: head '(' ')'
                    {
                    pushFollow(FOLLOW_head_in_list47);
                    head1=head();

                    state._fsp--;

                    match(input,16,FOLLOW_16_in_list49); 
                    match(input,17,FOLLOW_17_in_list51); 
                    System.out.println((head1!=null?input.toString(head1.start,head1.stop):null));

                    }
                    break;
                case 2 :
                    // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:17:4: head '(' first tail ')'
                    {
                    pushFollow(FOLLOW_head_in_list58);
                    head();

                    state._fsp--;

                    match(input,16,FOLLOW_16_in_list60); 
                    pushFollow(FOLLOW_first_in_list62);
                    first();

                    state._fsp--;

                    pushFollow(FOLLOW_tail_in_list64);
                    tail();

                    state._fsp--;

                    match(input,17,FOLLOW_17_in_list66); 

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "list"

    public static class head_return extends ParserRuleReturnScope {
    };

    // $ANTLR start "head"
    // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:20:1: head : ( 'define' | 'select' | ID );
    public final smalParser.head_return head() throws RecognitionException {
        smalParser.head_return retval = new smalParser.head_return();
        retval.start = input.LT(1);

        try {
            // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:20:7: ( 'define' | 'select' | ID )
            // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:
            {
            if ( input.LA(1)==ID||(input.LA(1)>=18 && input.LA(1)<=19) ) {
                input.consume();
                state.errorRecovery=false;
            }
            else {
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            }

            retval.stop = input.LT(-1);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "head"


    // $ANTLR start "first"
    // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:25:1: first : ID ;
    public final void first() throws RecognitionException {
        try {
            // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:25:7: ( ID )
            // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:25:9: ID
            {
            match(input,ID,FOLLOW_ID_in_first98); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "first"


    // $ANTLR start "tail"
    // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:28:1: tail : lists ;
    public final void tail() throws RecognitionException {
        try {
            // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:28:6: ( lists )
            // /home/cicciodarkast/Progetti/smal/1/smal-compiler/parser/smal.g:28:8: lists
            {
            pushFollow(FOLLOW_lists_in_tail109);
            lists();

            state._fsp--;


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "tail"

    // Delegated rules


 

    public static final BitSet FOLLOW_lists_in_main23 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_list_in_lists33 = new BitSet(new long[]{0x00000000000C0010L});
    public static final BitSet FOLLOW_lists_in_lists35 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_head_in_list47 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_16_in_list49 = new BitSet(new long[]{0x0000000000020000L});
    public static final BitSet FOLLOW_17_in_list51 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_head_in_list58 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_16_in_list60 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_first_in_list62 = new BitSet(new long[]{0x00000000000C0010L});
    public static final BitSet FOLLOW_tail_in_list64 = new BitSet(new long[]{0x0000000000020000L});
    public static final BitSet FOLLOW_17_in_list66 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_set_in_head0 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_first98 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_lists_in_tail109 = new BitSet(new long[]{0x0000000000000002L});

}